from ctypes import *

print ""
print "load compiled c code inside python"
l = cdll.LoadLibrary("./random.so")
f = l.getRandomInts
print l
print f

print ""
print "create return type"
ArrayOfTenInteger = c_int * 10
f.restype = POINTER(ArrayOfTenInteger)

print ""
print "call c code"
res = f(c_int(10), c_int(100))
r = list(res.contents)
# warning! print(res) cause infinite loop, be carefull

print ""
print "print 10 random number between 0 ad 100"
print r

print ""
print "now the struct"
class S(Structure):pass
S._fields_ = [  ("id", c_int),
		("p", POINTER(S))  ]

f = l.getTypedStruct
f.restype = POINTER(S)
res = f()
print res
res = res.contents
print dir(res)
print res.id
print res.p
res1 = res.p.contents
print res1.id
